home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / NumberFormatting.a < prev    next >
Encoding:
Text File  |  1998-02-12  |  4.6 KB  |  184 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        NumberFormatting.a
  3. ;
  4. ;    Contains:    Utilites for formatting numbers
  5. ;
  6. ;    Version:    Technology:    
  7. ;                Release:    Universal Interfaces 3.1
  8. ;
  9. ;    Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__NUMBERFORMATTING__') = 'UNDEFINED' THEN
  19. __NUMBERFORMATTING__ SET 1
  20.  
  21.     IF &TYPE('__CONDITIONALMACROS__') = 'UNDEFINED' THEN
  22.     include 'ConditionalMacros.a'
  23.     ENDIF
  24.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  25.     include 'MacTypes.a'
  26.     ENDIF
  27.     IF &TYPE('__INTLRESOURCES__') = 'UNDEFINED' THEN
  28.     include 'IntlResources.a'
  29.     ENDIF
  30.  
  31.  
  32. ;
  33. ;    Here are the current System 7 routine names and the translations to the older forms.
  34. ;    Please use the newer forms in all new code and migrate the older names out of existing
  35. ;    code as maintainance permits.
  36. ;    
  37. ;    New Name                    Old Name(s)
  38. ;    
  39. ;    ExtendedToString            FormatX2Str
  40. ;    FormatRecToString            Format2Str
  41. ;    NumToString                
  42. ;    StringToExtended            FormatStr2X
  43. ;    StringToFormatRec            Str2Format
  44. ;    StringToNum                
  45. ;
  46. ;
  47.  
  48. NumFormatString            RECORD 0
  49. fLength                     ds.b    1                ; offset: $0 (0)
  50. fVersion                 ds.b    1                ; offset: $1 (1)
  51. data                     ds.b    254                ; offset: $2 (2)        ;  private data 
  52. sizeof                     EQU *                    ; size:   $100 (256)
  53.                         ENDR
  54. NumFormatStringRec        RECORD 0
  55. f                         ds        NumFormatString
  56. sizeof                     EQU *                    ; size:   $100 (256)
  57.                         ENDR
  58.  
  59.  
  60. ; typedef short                         FormatStatus
  61.  
  62.  
  63. fVNumber                        EQU        0                    ; first version of NumFormatString 
  64. ; typedef SInt8                         FormatClass
  65.  
  66.  
  67. fPositive                        EQU        0
  68. fNegative                        EQU        1
  69. fZero                            EQU        2
  70. ; typedef SInt8                         FormatResultType
  71.  
  72.  
  73. fFormatOK                        EQU        0
  74. fBestGuess                        EQU        1
  75. fOutOfSynch                        EQU        2
  76. fSpuriousChars                    EQU        3
  77. fMissingDelimiter                EQU        4
  78. fExtraDecimal                    EQU        5
  79. fMissingLiteral                    EQU        6
  80. fExtraExp                        EQU        7
  81. fFormatOverflow                    EQU        8
  82. fFormStrIsNAN                    EQU        9
  83. fBadPartsTable                    EQU        10
  84. fExtraPercent                    EQU        11
  85. fExtraSeparator                    EQU        12
  86. fEmptyFormatString                EQU        13
  87. FVector                    RECORD 0
  88. start                     ds.w    1                ; offset: $0 (0)
  89. length                     ds.w    1                ; offset: $2 (2)
  90. sizeof                     EQU *                    ; size:   $4 (4)
  91.                         ENDR
  92. ;  index by [fPositive..fZero] 
  93. TripleInt                RECORD 0
  94. elements                 ds.b    3 * FVector.sizeof
  95. sizeof                     EQU *                    ; size:   $C (12)
  96.                         ENDR
  97.  
  98.  
  99. ;
  100. ; pascal void StringToNum(ConstStr255Param theString, long *theNum)
  101. ;
  102.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  103.         Macro
  104.         _StringToNum
  105.             move.w              #$0001,-(sp)
  106.             dc.w                $A9EE
  107.         EndM
  108.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  109.         IMPORT_CFM_FUNCTION StringToNum
  110.     ENDIF
  111.  
  112. ;
  113. ; pascal void NumToString(long theNum, Str255 theString)
  114. ;
  115.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  116.         Macro
  117.         _NumToString
  118.             move.w              #$0000,-(sp)
  119.             dc.w                $A9EE
  120.         EndM
  121.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  122.         IMPORT_CFM_FUNCTION NumToString
  123.     ENDIF
  124.  
  125.  
  126. ;
  127. ; pascal FormatStatus ExtendedToString(const extended80 *x, const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString)
  128. ;
  129.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  130.         Macro
  131.         _ExtendedToString
  132.             move.l              #$8210FFE8,-(sp)
  133.             dc.w                $A8B5
  134.         EndM
  135.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  136.         IMPORT_CFM_FUNCTION ExtendedToString
  137.     ENDIF
  138.  
  139. ;
  140. ; pascal FormatStatus StringToExtended(ConstStr255Param source, const NumFormatString *myCanonical, const NumberParts *partsTable, extended80 *x)
  141. ;
  142.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  143.         Macro
  144.         _StringToExtended
  145.             move.l              #$8210FFE6,-(sp)
  146.             dc.w                $A8B5
  147.         EndM
  148.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  149.         IMPORT_CFM_FUNCTION StringToExtended
  150.     ENDIF
  151.  
  152. ;
  153. ; pascal FormatStatus StringToFormatRec(ConstStr255Param inString, const NumberParts *partsTable, NumFormatString *outString)
  154. ;
  155.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  156.         Macro
  157.         _StringToFormatRec
  158.             move.l              #$820CFFEC,-(sp)
  159.             dc.w                $A8B5
  160.         EndM
  161.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  162.         IMPORT_CFM_FUNCTION StringToFormatRec
  163.     ENDIF
  164.  
  165. ;
  166. ; pascal FormatStatus FormatRecToString(const NumFormatString *myCanonical, const NumberParts *partsTable, Str255 outString, TripleInt positions)
  167. ;
  168.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  169.         Macro
  170.         _FormatRecToString
  171.             move.l              #$8210FFEA,-(sp)
  172.             dc.w                $A8B5
  173.         EndM
  174.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  175.         IMPORT_CFM_FUNCTION FormatRecToString
  176.     ENDIF
  177.  
  178.  
  179.     IF OLDROUTINENAMES THEN
  180.     ENDIF    ; OLDROUTINENAMES
  181.     ENDIF ; __NUMBERFORMATTING__ 
  182.  
  183.